package com.base64Coding;

/**
 * @ program: elasticSearch_springBoot_study
 * @ description:
 * @ author: Mr.Zhongsf
 * @ create: 2021-06-17 14:41
 **/
public class Base64 {
    public static void main(String[] args) {

        System.out.println(getBase64("钟山峰"));


    }



    public static String getBase64(String str){
        byte[] bytes = str.getBytes();

        //加密
        String strReturn = java.util.Base64.getEncoder().encodeToString(bytes);
        System.out.println("base 64 加密后:" + strReturn );

        //解密
        byte[] decodeByte = java.util.Base64.getDecoder().decode(strReturn);
        String decodeStr = new String(decodeByte);
        System.out.println("解密后" +decodeStr);
        return strReturn;

    }



}
